﻿
@{
    ViewBag.Title = "ModalUpload";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!--模态框 单独模块-->
<div id="imgModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" style="width: 900px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title">上传图片</h4>
            </div>
            <div class="modal-body model-scroll" style="max-height: 500px;">
                <!--上传图片start-->
                <div id="wrapper">
                    <div id="container">
                        <div id="uploader">
                            <div class="queueList">
                                <div id="dndArea" class="placeholder">
                                    <div id="filePicker"></div>
                                    <p>或将照片拖到这里，并支持截图粘贴功能</p>
                                </div>
                            </div>
                            <div class="statusBar" style="display: none;">
                                <div class="progress">
                                    <span class="text">0%</span>
                                    <span class="percentage"></span>
                                </div>
                                <div class="info"></div>
                                <div class="btns">
                                    <div id="filePicker2"></div>
                                    <div class="uploadBtn">开始上传</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--上传图片end-->
            </div>
        </div>
    </div>
</div>
<button id="openUpload" type="button" class="btn btn-primary" data-toggle="modal" data-target="#imgModal">上传图片</button>

<script>
    $(function () {
        var callback = function (response) {
            if (response.Status == 200) {
                new PNotify({ title: "成功！", text: response.Message, type: 'success' });// 此处使用了Pnotify 插件== alert
            } else {
                new PNotify({ title: "失败！", text: response.Message, type: 'error' });
            }
        };


        //打开模态框-初始化图片插件
        $('#imgModal').on('shown.bs.modal', function () {
            _init_upload(callback);
        });
        //关闭模态框-销毁对象         
        $('#imgModal').on('hidden.bs.modal', function () {
            if (typeof (uploader) != "undefined") {
                uploader._destroy();
            }
        });
    });
</script>
